package org.gap.wizards.world.actions;

import java.awt.Point;

import org.gap.wizards.items.Item;
import org.gap.wizards.pc.PlayerCharacter;
import org.gap.wizards.world.Location;
import org.gap.wizards.world.WorldAction;

public class PickupItemsAction implements WorldAction {

	private final PlayerCharacter pc;
	private final Location map;
	private final Point toPickupFrom;

	public PickupItemsAction(PlayerCharacter pc, Location map) {
		this.pc = pc;
		this.map = map;
		this.toPickupFrom = map.getCharacterLocation();
	}

	@Override
	public void perform() {
		for (Object each : map.getAllFromLocation(toPickupFrom)) {
			if (each instanceof Item) {
				pc.addItem((Item)each);
				map.removeItem((Item)each);
			}
		}
	}

}
